//
//  GRMyOwnHeaderReusableView.m
//  YC_GRice
//
//  Created by Feng Liu on 2018/8/29.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRMyOwnHeaderReusableView.h"
#import "GRMyInfomationViewController.h"
#import "GRMyGRiceViewController.h"

@implementation GRMyOwnHeaderReusableView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initiazation code
    self.topBackgroundView.backgroundColor = KGMTHEM_COLOR;
}

-(void)setModel:(GRPersonModel *)model {
    _model = model;
    if ([GRUserBasisInfo isLogin] && model) {
        [_avatars sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"usercenter_14"]];
        _nickName.text         = model.nickname;
        _myRice.text            = [NSString stringWithFormat:@"%.2f",model.viewPoint];
    }else {
        _avatars.image         = [UIImage imageNamed:@"usercenter_14"];
        _nickName.text         = @"登录/注册";
        _myRice.text            = @"0.00";
    }
}


/**
 登录

 @param sender <#sender description#>
 */
- (IBAction)loginAction:(UIButton *)sender {
    [self.currentVc haveLoginOperation:^{
        GRMyInfomationViewController *info = [[GRMyInfomationViewController alloc] initWithStyle:UITableViewStylePlain];
        [self.currentVc.navigationController pushViewController:info animated:YES];
    }];
}


/**
 我的龟米

 @param sender <#sender description#>
 */
- (IBAction)goToMyRiceAction:(id)sender {
    [self.currentVc haveLoginOperation:^{
        GRMyGRiceViewController *griceVc = [[GRMyGRiceViewController alloc] initWithStyle:UITableViewStylePlain];
        [self.currentVc.navigationController pushViewController:griceVc animated:YES];
    }];
}


@end
